home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DJLSR106.ARJ / MM.C < prev    next >
C/C++ Source or Header  |  1992-03-02  |  2KB  |  67 lines

  1. /* This is file mm.c */
  2. /*
  3. ** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  4. **
  5. ** This file is distributed under the terms listed in the document
  6. ** "copying.dj", available from DJ Delorie at the address above.
  7. ** A copy of "copying.dj" should accompany this file; if not, a copy
  8. ** should be available from where this file was obtained.  This file
  9. ** may not be distributed without a verbatim copy of "copying.dj".
  10. **
  11. ** This file is distributed WITHOUT ANY WARRANTY; without even the implied
  12. ** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. */
  14.  
  15. #include <stdio.h>
  16. #include <string.h>
  17. #include <ctype.h>
  18.  
  19. main()
  20. {
  21.   FILE *fin, *fout;
  22.   char buf[200];
  23.   fin = fopen("maketmpl", "r");
  24.   fout = fopen("makefile.n", "w");
  25.   fprintf(fout, "# This file is generated from maketmpl by mm.c\n");
  26.   while (fgets(buf, 200, fin) != NULL)
  27.   {
  28.     if (strncmp(buf, "@dir ", 5) == 0)
  29.       handle_dir(fout, buf+5);
  30.     else
  31.       fputs(buf, fout);
  32.   }
  33.   fclose(fin);
  34.   fclose(fout);
  35. }
  36.  
  37. handle_dir(FILE *f, char *line)
  38. {
  39.   char fname[100];
  40.   sscanf(line, "%s", fname);
  41.   handle_wild(f, fname, "*.c");
  42.   handle_wild(f, fname, "*.cc");
  43.   handle_wild(f, fname, "*.S");
  44. }
  45.  
  46. #include <dir.h>
  47. #include <dos.h>
  48.  
  49. handle_wild(FILE *f, char *dir, char *wild)
  50. {
  51.   struct ffblk ff;
  52.   char buf[100], *cp;
  53.   int done;
  54.   sprintf(buf, "%s/%s", dir, wild);
  55.   done = findfirst(buf, &ff, FA_ARCH | FA_RDONLY);
  56.   while (!done)
  57.   {
  58.     fputs("\t$(ODIR)/", f);
  59.     sprintf(buf, "%s", ff.ff_name);
  60.     strlwr(buf);
  61.     cp = strrchr(buf, '.');
  62.     strcpy(cp, ".o \\\n");
  63.     fputs(buf, f);
  64.     done = findnext(&ff);
  65.   }
  66. }
  67.